/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86136
 * Date: 2024-05-18
 * Time: 21:26
 */
public class Date {
    int year;
    int month;
    int day;

    public Date() {
        this(2008,2,9);//必须是构造方法中第一条语句

        //可以进行初始化
        /*this.year = 2008;
        this.month = 2;
        this.day = 4;*/
        System.out.println("调用了无参构造方法");
    }
    public Date(int year,int month,int day) {
        this.year = year;
        this.month = month;
        this.day = day;
        System.out.println("调用了带有3个的参构造方法");

    }
    public void setDate(int year,int month,int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }
    public void printDate() {
        System.out.println(this.year + "年 " + this.month + "月 " + this.day + "日");
        test();
    }
    public void test() {
        System.out.println("测试一下this...");
    }

    public static void main(String[] args) {
        Date date =new Date(2008,2,8);
        date.printDate();
    }
    public static void main1(String[] args) {
        Date date =new Date();
        date.setDate(2008,1,3);
        date.printDate();
        System.out.println("==================");
        Date date1 = new Date();
        date1.setDate(2004,9,1);
        date1.printDate();
        System.out.println("==================");
        Date date2 = new Date(2010,3,2);
        date2.printDate();
        //System.out.println(this.day);//this 不能在静态方法中使用
    }
}
